﻿using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;

namespace MDCAdminTool
{
    public class DataCacheConfigSection : ConfigurationSection
    {
        // Fields
        internal const string CLUSTER_NAME  = "clusterName";
        internal const string CONFIG        = "clusterConfig";
        internal const string DCACHE        = "dataCacheConfig";
        internal const string HOST_NAME     = "hostName";
        internal const string LOGGING       = "log";
        internal const string SERVICE_NAME  = "cacheHostName";
        internal const string TIMEOUT       = "timeout";

        // Methods
        public DataCacheConfigSection()
        {
            this.ClusterName = "";
            this.HostName = "";
            this.CacheHostName = "";
        }

        // Properties
        [ConfigurationProperty( "cacheHostName" , DefaultValue="" , IsRequired=true )]
        internal string CacheHostName
        {
            get
            {
                return (string)base["cacheHostName"];
            }
            set
            {
                base["cacheHostName"] = value;
            }
        }

        [ConfigurationProperty( "clusterConfig" , IsRequired=true )]
        internal ClusterConfigElement ClusterConfig
        {
            get
            {
                return (ClusterConfigElement)base["clusterConfig"];
            }
            set
            {
                base["clusterConfig"] = value;
            }
        }

        [ConfigurationProperty( "clusterName" , DefaultValue="" , IsRequired=true )]
        internal string ClusterName
        {
            get
            {
                return (string)base["clusterName"];
            }
            set
            {
                base["clusterName"] = value;
            }
        }

        [ConfigurationProperty( "hostName" , DefaultValue="" , IsRequired=true )]
        internal string HostName
        {
            get
            {
                return (string)base["hostName"];
            }
            set
            {
                base["hostName"] = value;
            }
        }

        //[ConfigurationProperty("log", IsRequired=false)]
        //internal LogConfigElement Log
        //{
        //    get
        //    {
        //        return (LogConfigElement) base["log"];
        //    }
        //    set
        //    {
        //        base["log"] = value;
        //    }
        //}

        internal static string Name
        {
            get
            {
                return "dataCacheConfig";
            }
        }

        [ConfigurationProperty( "timeout" , DefaultValue=0x3a98 , IsRequired=false )]
        internal int Timeout
        {
            get
            {
                return (int)base["timeout"];
            }
            set
            {
                base["timeout"] = value;
            }
        }

        public string Provider { get; set; }
        public string ConnectionString { get; set; }
    }
}
